<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ES6 对象解构</title>
</head>
<body>
<script>
    let person = {
        name: "abc",
        gender: "男",
        age: 18
    };

    /*
    // 最大的问题：重复
    let name = person.name;
    let gender = person.gender;
    let age = person.age;

    console.log(name);
    console.log(gender);
    console.log(age);
    */

    /*
    // 按照对象属性进行解构
    let {name, gender, age} = person;

    console.log(name);
    console.log(gender);
    console.log(age);
    */

    /*
    // 解构后的顺序与真是的顺序无关
    let {gender, name, age} = person;

    console.log(name);
    console.log(gender);
    console.log(age);
    */

    let {name,  age} = person;

    console.log(name);
    console.log(age);

</script>
</body>
</html>